********************************************************************************
* Purpose: Imams data analysis - scaleup Eid ul Azha 2020 
* Sub-file: main table mystery shoppers 
********************************************************************************

	****************************************************************************
	* Load data
	****************************************************************************

	use			"${imamsurvey}/merged_scaleup.dta" , clear 
	
	keep		if consent_statement==1											// Restrict the sample here to people who responded in the baseline T / C calls
																				

	****************************************************************************
	* Estimates
	****************************************************************************

	estimates	clear 
	
	global		estimatesshort ""
	global		estimates ""
	global		estimatesplot ""

	local		j = 0 
	
	foreach		i in $msoutcomes {

				local		j = `j' + 1
	
				* T vs. C
	
				reg 		`i' treatment_any , robust 						
	
				est			sto est`j'_1
				
				sum			`i' if treatment_any==0 
				estadd		scalar cmean = r(mean) 

				
				* T1 vs. T2 vs. C - no controls
	
				reg 		`i' treatment_combined treatment_secular , robust 						
				
				est 		sto est`j'_2
				
				estadd		local covariates "No"
				
				test 		treatment_combined = treatment_secular
				estadd 		scalar pval = round(r(p), .01)
				
				test		treatment_combined = treatment_secular = 0 
				estadd 		scalar pvaljoint = round(r(p), .01)				

				
				* T1 vs. T2 vs. C - with controls
				
				reg 		`i' treatment_combined treatment_secular ///
								prevention_step_0*, robust 		
				
				est 		sto est`j'_3
				
				estadd		local covariates "Yes"
				
				test 		treatment_combined = treatment_secular
				estadd 		scalar pval = round(r(p), .01)
				
				test		treatment_combined = treatment_secular = 0 
				estadd 		scalar pvaljoint = round(r(p), .01)				
				
				
				local		labi : variable label `i' 
				
				global		estimatesplot $estimatesplot ( est`j'_1 , label(`labi'))
				

	}

	****************************************************************************
	* Table 
	****************************************************************************
	
	esttab		*_1 using "${texrct}/scaleup_ms_main.tex" , ///
					replace star(* .1 ** .05 *** .01) se  t(3) b(3) label ///
					keep(treatment*) ///
					scalars("cmean Control group mean") ///
					nonotes fragment  nonumbers booktabs 
					
	esttab		*_2 using "${texrct}/scaleup_ms_arms.tex" , ///
					replace star(* .1 ** .05 *** .01) se  t(3) b(3) label ///
					scalars("covariates Covariates" ///
					"pval P-value, treatment effects equal") ///
					keep(treatment*) ///
					nonotes fragment nonumbers booktabs

